package com.cn.wanxi.servlet;

import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.service.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteNewsById")
public class DeleteNewsById  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//       1.得到id
        String idstring=req.getParameter("id");
//        2.封装model
        NewsModel newsModel=new NewsModel();
        newsModel.setId(Integer.parseInt(idstring));
//        3.条用逻辑层
        NewsService newsService=new NewsService();
        newsService.delete(newsModel);
//        4.跳转页面
        resp.sendRedirect("newsPage");

    }
}
